const privateMsgDao = require('../dao/privateMsgDao')
const jwt = require('jsonwebtoken')
const config = require('../config/config.js')

// 添加
exports.add = async ctx => {
  let body = ctx.request.body
  console.log(body);
  const res = await privateMsgDao.create(body);
  ctx.success('创建成功')
}

// 获取信息
exports.get = async ctx => {
  let { sender,receiver } = ctx.request.query;  
  const res = await privateMsgDao.findAllMsg(sender,receiver)
  ctx.success('',res)
}

// 删除某条数据
exports.del = async ctx => {
  let { id } = ctx.request.query
  const res = await privateMsgDao.delById(id);
  ctx.success('删除成功')
}

// 修改某条数据
exports.upd = async ctx => {
  let body = ctx.request.body
  const res = await privateMsgDao.upd(body);
  ctx.success('修改成功')
}
